﻿$(function ()
{
    var chat = $.connection.chatHub;
    chat.client.broadcastMessage = function (name, message)
    {
        var encodedName = $('<div />').text(name).html();
        var encodedMsg = $('<div />').text(message).html();
        $('#discussion').append('<li><strong>' + encodedName+ '</strong>:&nbsp;&nbsp;' + encodedMsg + '</li>');
    };
    document.getElementById("Displayname").value = g_username;
 
    $('#Message').focus();
    $.connection.hub.start().done(function () 
    {
        $('#Sendmessage').click(function ()
        {
            chat.server.send($('#Displayname').val(), $('#Message').val());
            $('#Message').val('').focus();
        });
    });
});